package main

import (
	"fmt"
	"sync"
	"time"
)

var SQLS []*SqlStruct
var sqlMutex sync.Mutex

type CustomTime time.Time

func (t CustomTime) MarshalJSON() ([]byte, error) {
	return []byte(fmt.Sprintf("\"%s\"", time.Time(t).Format("2006-01-02 15:04:05"))), nil
}

type SqlStruct struct {
	Id       string       `json:"id"`
	Sql      string       `json:"sql"`
	Datetime CustomTime   `json:"datetime"`
	Result   *queryResult `json:"-"`
}

type queryResult struct {
	Columns      []ColumnDefinition `json:"columns"`
	Rows         [][]interface{}    `json:"rows"`
	AffectedRows int64              `json:"affected_rows"`
	LastInsertID int64              `json:"last_insert_id"`
}
